﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ExpertMIS.Entities;
using System.Text;
using ExpertMIS.Brokers;

namespace ExpertMIS.UserControl
{
    public partial class ucExpertShort : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        public ExpertEntity Expert
        {
            set
            {
                hlName.Text = value.Name;
                hlName.NavigateUrl = "~/Forums/ExpertView.aspx?oid=" + value.OID;

                hlToExpert.NavigateUrl = "~/Forums/ExpertView.aspx?oid=" + value.OID;
                
                lblPhone.Text = value.Phone;

                ExpertBroker expertBroker = new ExpertBroker();
                StringBuilder sb = new StringBuilder();
                foreach (DomainEntity domain in expertBroker.GetExpertDomains(value.OID))
                {
                    if (domain == null) continue;
                    if (sb.Length > 0) sb.Append(",");
                    sb.Append(string.Format("<a href='{0}?oid={1}' alt=''>{2}</a>", ResolveClientUrl("~/Forums/DomainIntroduce.aspx"), domain.OID, domain.DomainName, domain.Remark));
                }

                lblDomains.Text = sb.ToString();
                imgPhoto.ImageUrl = "~/Service/GetPhoto.aspx?w=128&h=128&filename=" + value.Graphic;
                imgPhoto.AlternateText = value.Name;
            }
        }
    }
}